waterconsumptionesp32thingspeakfandomcom-20200213-history
Water Consumption-ESP32-ThingSpeak Wiki
Welcome to the WaterConsumption_ESP32_ThingSpeak Wiki Iot is the new trend of the 21th century . We decided with colleagues to create a water consumption counter with simple implemented tools & devices . ESP 32 & ThingSpeak server ! Context A school director asked us to create a small device which provides the water consumption of his institute. A cheap device, which is controllable at a certain distance, which energy consumption is low and which is able to communicate the results on a web page server, those were the constraints of this project. So, we decided to use an ESP32 module connected to a ThingSpeak server that receives in real time the consumption measurements. The aim of the project is to find out : * How an ESP32 microcontroller can store and retrieve data from a flow meter ? * How do we manage the wifi communication ? * How will we provide understandable results ? Tranmissions General principle The material used for this project is constituted by : * ESP32 a Wi-Fi antenna * Arduino Uno of a fluch or shower consumption * ThingSpeak Server time plot Layers scheme Wi-Fi protocol & ThingSpeak server We use the Wi-Fi protocol to transmit data between the esp32 card and the Wifi router. The protocol explained here is limited by the standards IEEE 802.11, it has been developed since 1999 to improve its characteristics (range, capacity, data bit rate and so on). The norm is characterized by a bloc layer organization, it defines the specifications linked to the used of the Physical and MAC layer. The architecture of a Wi-Fi network can be of two types: * Ad Hoc or independent network: two stations can directly communicate between them. * Infrastructure network: in that case when two stations want to talk to each other they must communicate through an access point. ESP32 -> Rooter : * The including of the library * The definition of the SSID and password of the network we want to connect to * The scanning of the network: the esp32 scan all the area and will watch all the available wifi network, more it registers data about that wifi networks * The connecting to the network: the esp32 connect to the network we define earlier * Beginning of the transmission from the esp32 to the distribution network by the rooter ESP 32 ->ThingSpeak : The esp32 send the data emuled by the Arduino under JSON format (special format permitting to inform about the time and date of the transmission and the value of it). The json files is send to a special channel, with a special id who has been created earlier. The data are stored in a special place in the server and after, the website came back to read the data and to refresh the webpage of the channel. The transmission is made in three times: esp32 to Gateway by the Wifi router; Gateway to server of Thingspeak; displacement of data between Thingspeak servers (storage -> website). How do we calculate the water consumption ? A flow meter is composed of a turbine that turns when water passes through it. As water is an incompressible fluid, the number of rotations gives the volume of water that has passed through the meter. A mechanical counter is coupled to the turbine and allows to know the volume of water consumed since the installation of the meter. Some flow meters can send a signal via a simple digital output on two cables. A pulse is sent each time a determined volume is consumed (generally 1 liter). Tools Arduino environment “Arduino is an open-source electronics platform based on easy-to-use hardware and software”1. Its main characteristics are its open source platform that uses the Arduino programming language and the IDE environment and the worldwide community of makers that creates accessible knowledge for the users of this technology. Reasons why to use this technology does not lack. Some advantages: Cross-platform meaning that its software, the IDE, runs on Windows, Mac and Linux systems; Simple programming environment so it is easy to learn and use for beginners and flexible for advanced programmers. Arduino was designed for school kids to get a taste of programming and hardware design. Reason why it’s a well used tool for many professors and teachers; Inexpensive, its boards are cheap compared to other microcontrollers; Open Source; Spreaded technology with a huge community; Extensible Software, Arduino language is based on AVR-C and can be expanded through C++ libraries, so it is possible to add AVR-C and C++ codes directly into the IDE; Extensible hardware so creators constantly use it as a circuit builder and make their own modules. However, this platform has also some disadvantage, having issues with advanced programs with a large complexity and real time projects. Therefore Arduino, a basic embedded system design, is the best platform for beginners compared to others of the same type in the market, even so it is not suitable for advanced systems. So, by the last years it has been used as the main resource for many electronic projects such as low cost scientific instruments, introduction for programming and robotics, interactive architecture designs and others. In this project, it was used the Arduino Uno Board2. It is the first in a series of USB Arduino boards and it is a microcontroller based on ATmega328P that has 14 digital input/output pins, which 6 provides PWM output, and 6 analog inputs. It works with an input voltage of 6 till 20V, and a DC current per I/O pin of 20mA and for 3.3V pin of 50mA. Its clock speed is of 16MHz, has a flash memory of 32KB and its SRAM and EEPROM is the ATmega328P ones. ESP 32 The ESP3212is a series of SoC (system on a chip) with integrated Wi-Fi and a dual-mode Bluetooth. Because it was engineered for mobile and wearable devices and IoT, It is a low cost and low-power microcontroller system created and developed by the Shanghai-based company Espressif Systems. ESP32s CPU is a Xtensa dual or single-core of 32-bit LX6 microprocessor operating at 160 or 240 MHz with a SRAM memory of 520KB and is highly-integrated with built-in antenna switches, RF balun, power amplifier, low-noise receive amplifier, filters and power management modules, which means that it has a versatility with a minimal PCB requirement. Because of its SPI/SDIO or I2C/UART interfaces, the ESP32 series can provide Wi-Fi and Bluetooth functionality to other systems. So is evident that it can work as a standalone system or a slave device to a MCU that, for example, needs to reduce the communication stack overhead on its main application processor. It is also a trustful device for extreme condition situation such as industrial environments or external areas where there is a lot of noise, external circuit imperfections and hostile environment. This is possible due to its robust design with an advanced calibration circuitries. So, for example, it can operate in a temperature range from -40ºC to 125ºC. ESP32 also achieves ultra-low power consumption that is due to power saving features including fine resolution clock gating, multiple power modes and dynamic power scaling. ThingSpeak ThingSpeak is an IoT analytics platform service to aggregate, visualize and analyze data in the cloud retrieved from a variety of devices using the HTTP protocol. Followed by its developers, ThingSpeak is an open source ap plication that can collect real-time data privately to the cloud, analyze and process data executing Matlab codes, visualize this data and trigger a reaction out of it. This IoT tool works, aggregating data, with microcontrollers, applications and HTTP such as Arduino, ESP8266, Raspberry Pi, Twitter, Matlab, mobiles and web apps. And it allows to visualize your sensor data in real-time, analyze automatically your data based on schedule events and prototype IoT systems without setting up servers at local channels or Ethernet. And it has private and public channels, where you can work and share, or not, your project, RESTful and MQTT APIs, alerts, event scheduling, App integration and a vast and worldwide community. Conclusion In this project, the main idea was to illustrate the usefulness of IoT in a daily situation: analysis of the water consumption in a school to help water leak avoidance. To achieve this task, we selected some tools like the Arduino platform to simulate the water consumption for a shower or a flush, we used, a ESP32 microcontroller to store and manage data of the consumption, Wifi protocol to transmit information to the user and Thingspeak to receive data and plot a real-time graph. As results, we can observe a real-time graph on the Thingspeak platform that provides us data about the water consumption each minute (data are stocked each 15s in the ESP and send to the platform each minute). The goal was to help in water leak avoidance in a school. Indeed, if a toilet flush in such a building, it’s difficult to see it without waste water before. With Thingspeak, someone can often control if something is wrong. As perspective in this work, one improvement can be the management of the sink faucet to control if nobody forgets to close the valve. Latest activity Photos and videos are a great way to add visuals to your wiki. Add one below! Category:Browse